package com.wetool.wechat.feign;

import com.wetool.wechat.model.QrCodeRequest;
import com.wetool.wechat.model.official.AccessTokenResponse;
import com.wetool.wechat.model.official.ErrorMessage;
import com.wetool.wechat.model.official.OfficialUserInfo;
import com.wetool.wechat.model.official.menu.MenuGroup;
import com.wetool.wechat.model.official.menu.conditaional.ConditionalMenuGroup;
import com.wetool.wechat.model.official.template.MessageResponse;
import com.wetool.wechat.model.official.template.TemplateMessageRequest;
import feign.Param;
import feign.RequestLine;

/**
 * 微信公众号接口
 */

public interface WechatOfficialFeignClient {

    /**
     * 获取微信公众号的accessToken
     *
     * @param appId
     * @param appSecret
     * @return
     */
    @RequestLine("GET /cgi-bin/token?grant_type=client_credential&appid={appId}&secret={appSecret}")
    AccessTokenResponse accessToken(@Param(value = "appId") String appId, @Param(value = "appSecret") String appSecret);


    /**
     * 发送模板消息
     *
     * @param accessToken
     * @return
     */
    @RequestLine("POST /cgi-bin/message/template/send?access_token={accessToken}")
    MessageResponse sendMessage(@Param("accessToken") String accessToken, TemplateMessageRequest message);

    @RequestLine("POST /cgi-bin/qrcode/create?access_token={accessToken}")
    Object createQrCode(@Param("accessToken") String accessToken, QrCodeRequest request);



    /**
     * @param accessToken
     * @return
     */
    @RequestLine("POST /cgi-bin/template/get_all_private_template?access_token={accessToken}")
    Object getMessageTemplate(@Param("accessToken") String accessToken);

    /**
     * @param accessToken
     * @return
     */
    @RequestLine("GET /cgi-bin/getcallbackip?access_token={accessToken}")
    Object getIpList(@Param("accessToken") String accessToken);

    /**
     * 获取用户信息(包含unionId)
     *
     * @param accessToken
     * @param openId
     * @return
     */
    @RequestLine("GET /cgi-bin/user/info?access_token={accessToken}&openid={openId}&lang=zh_CN")
    OfficialUserInfo userInfo(@Param("accessToken") String accessToken, @Param("openId") String openId);


    /**
     * 创建微信自定义菜单
     *
     * @param accessToken
     * @param group
     * @return
     */
    @RequestLine("POST /cgi-bin/menu/create?access_token={accessToken}")
    ErrorMessage createMenu(@Param("accessToken") String accessToken, MenuGroup group);

    /**
     * 查询微信自定义菜单
     *
     * @param accessToken
     * @return
     */
    @RequestLine("GET /cgi-bin/menu/get?access_token={accessToken}")
    ConditionalMenuGroup queryMenu(@Param("accessToken") String accessToken);

    /**
     * 删除微信自定义菜单
     *
     * @param accessToken
     * @return
     */
    @RequestLine("GET /cgi-bin/menu/delete?access_token={accessToken}")
    ErrorMessage deleteMenu(@Param("accessToken") String accessToken);

    /**
     * 创建微信个性化菜单
     *
     * @return
     */
    @RequestLine("POST /cgi-bin/menu/addconditional?access_token={accessToken}")
    ErrorMessage createConditional(@Param("accessToken") String accessToken, ConditionalMenuGroup group);

    /**
     * 删除微信个性化菜单
     *
     * @return
     */
    @RequestLine("GET /cgi-bin/menu/delconditional?access_token={accessToken}")
    ErrorMessage deleteConditional(@Param("accessToken") String accessToken);

    /**
     * 测试微信个性化菜单匹配
     *
     * @return
     */
    @RequestLine("POST /cgi-bin/menu/trymatch?access_token={accessToken}")
    Object testConditaional(@Param("accessToken") String accessToken);


    @RequestLine("GET /cgi-bin/customservice/getonlinekflist?access_token={accessToken}")
    Object customer(@Param("accessToken") String accessToken);
}